﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PortalLogReport.Models
{
    public class BarChartViewModel : BaseChartViewModel
    {
        public string XAxisData { get; set; }

        public static BarChartViewModel ConvertToViewModel(string xAxisData, Dictionary<string, int> data)
        {
            BarChartViewModel viewData = new BarChartViewModel();
            viewData.XAxisData = xAxisData;
            viewData.SeriesDataSet = new List<SeriesData>();
            if (data != null && data.Count > 0)
            {
                foreach (var series in data.Keys)
                {
                    viewData.SeriesDataSet.Add(new SeriesData
                    {
                        Name = series,
                        Value = data[series]
                    });
                }
            }

            return viewData;
        }
    }

}